package com.example.nio.security.custom;

import cn.hutool.json.JSONUtil;
import com.example.nio.commons.Agent;
import com.example.nio.commons.Result;
import com.example.nio.utils.AgentUserUtil;
import com.example.nio.utils.AssignedUtil;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutHandler;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class MyLogoutSuccessHandler implements LogoutSuccessHandler {

    @Override
    public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
        System.out.println("用户成功退出");
        System.out.println("登出成功");
        response.setContentType("application/json;charset=UTF-8");
        response.getWriter().write(JSONUtil.toJsonStr(Result.ok("注销成功！")));
    }
}
